package me.zk.practice1.s;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

/**
 * @author zhangkai
 * @date 2023/7/31 09:35
 */
public class LS_Offer2_026 {
    public static void reorderList(ListNode head) {
        if (head == null) {
            return;
        }
        List<ListNode> list = new ArrayList<>();
        ListNode node = head;
        while (node != null) {
            list.add(node);
            node = node.next;
        }
        int l = 0;
        int r = list.size() -1;
        while (l < r) {
            list.get(l).next = list.get(r);
            l++;
            if (l == r) {
                break;
            }
            list.get(r).next = list.get(l);
            r--;
        }
        list.get(r).next = null;

    }

    public static void main(String[] args) {
        ListNode noe = new ListNode(1,new ListNode(2,new ListNode(3,new ListNode(4))));
        reorderList(noe);
    }
}
